(function () {
    var provinceDom = document.getElementById('province'),
        cityDom = document.getElementById('city'),
        schoolDom = document.getElementById('school');
    for (var prop in province) {
        var optionDom = document.createElement('option')
        optionDom.value = prop
        optionDom.innerHTML = province[prop]
        provinceDom.appendChild(optionDom)
    }

    provinceDom.onchange = function () {
        var p = provinceDom.value
        if (p == '0000') {
            cityDom.innerHTML = ''
            schoolDom.innerHTML = ''
            return
        }
        var cityObj = city[p]
        cityDom.innerHTML = ''
        schoolDom.innerHTML = ''
        for (var prop in cityObj) {
            var optionDom = document.createElement('option')
            optionDom.value = prop
            optionDom.innerHTML = cityObj[prop]
            cityDom.appendChild(optionDom)
        }

        var s = cityDom.value
        var schoolArr = allschool[s]
        for (var i = 0; i < schoolArr.length; i++){
            var optionDom = document.createElement('option')
            optionDom.innerHTML = schoolArr[i]
            schoolDom.appendChild(optionDom)
        }
    }

    cityDom.onchange = function () {
        var s = cityDom.value
        var schoolArr = allschool[s]
        schoolDom.innerHTML = ''
        console.log(schoolArr);
        for (var i = 0; i < schoolArr.length; i++){
            var optionDom = document.createElement('option')
            optionDom.innerHTML = schoolArr[i]
            schoolDom.appendChild(optionDom)
        }

    }
})()